package cn.btks.resultintegration.achievements.repository;

import cn.btks.resultintegration.achievements.pojo.AchievementsTemp;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.Date;

/**
 * @Author lijun
 * @Date 2021/2/20 9:14
 */
@Repository
public interface AchievementsTempRepository extends JpaRepository<AchievementsTemp, Long>, JpaSpecificationExecutor<AchievementsTemp> {

    /**
     * 人工审核
     * @param isApproved
     * @param verifyContent
     * @param achievementTempId
     * @param verifyDate
     * @return
     */
    @Modifying
    @Query(value = "update achievements_temp set is_approved=?1,verify_content=?2,upload_date=?4,verify_type = 1 where id = ?3", nativeQuery = true)
    int manualVerify(Integer isApproved, String verifyContent, Long achievementTempId, Date verifyDate);

    /**
     * 更新审核人信息
     * @param verifyUser
     * @param verifyUnit
     * @param id
     * @return
     */
    @Modifying
    @Query(value = "update achievements_temp set verify_user=?1,verify_unit=?2 where id = ?3", nativeQuery = true)
    int updateVerifyUser( String verifyUser, String verifyUnit, Long id);
}
